home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / flex_247.zip / flex_247 / MISC / MSDOS / Turbo-C.notes < prev   
Text File  |  1989-09-01  |  6KB  |  270 lines

  1. (Message inbox:25)
  2. Date:  Tue, 29 Aug 89 18:57:48 pst
  3. From:  few@quad1.quad.com (Frank Whaley)
  4. Subject:  Re: flex 2.1 for Turbo C
  5. To:  vern@cs.cornell.edu
  6.  
  7. > Sorry it's taken me so long to get back to you - I've been out of touch
  8. > for about the last month.
  9.  
  10. I didn't expect to hear from you soon -- hope your journey was nice.
  11.  
  12. > I'd like to have your 'adjustments' for Turbo C, so if you still have
  13. > them lying conveniently around, please mail them to me.  Thanks.
  14.  
  15. After a little more fiddling, the changes are relatively small.  Probably
  16. the largest problem is that Turbo C does not yet claim to adhere to the
  17. draft standard, so even though they support many "modern" constructs, they
  18. still are not __STDC__.  Thus the diffs from flex.skl (note the name):
  19.  
  20.     62c62
  21.     < #if defined(__STDC__) || defined(__TURBOC__)
  22.     ---
  23.     > #ifdef __STDC__
  24.     104c104
  25.     < #if !(defined(__STDC__) || defined(__TURBOC__))
  26.     ---
  27.     > #ifndef __STDC__
  28.     134c134
  29.     < #if defined(__STDC__) || defined(__TURBOC__)
  30.     ---
  31.     > #ifdef __STDC__
  32.     390c390
  33.     < #if defined(__STDC__) || defined(__TURBOC__)
  34.     ---
  35.     > #ifdef __STDC__
  36.     482c482
  37.     < #if defined(__STDC__) || defined(__TURBOC__)
  38.     ---
  39.     > #ifdef __STDC__
  40.  
  41. and initscan.c:
  42.  
  43.     63c63
  44.     < #if defined(__STDC__) || defined(__TURBOC__)
  45.     ---
  46.     > #ifdef __STDC__
  47.     105c105
  48.     < #if !(defined(__STDC__) || defined(__TURBOC__))
  49.     ---
  50.     > #ifndef __STDC__
  51.     677c677
  52.     < #if defined(__STDC__) || defined(__TURBOC__)
  53.     ---
  54.     > #ifdef __STDC__
  55.     1658c1658
  56.     < #if defined(__STDC__) || defined(__TURBOC__)
  57.     ---
  58.     > #ifdef __STDC__
  59.     1750c1750
  60.     < #if defined(__STDC__) || defined(__TURBOC__)
  61.     ---
  62.     > #ifdef __STDC__
  63.  
  64. are pretty simple.  BTW, simply adding -D__STDC__=1 to CFLAGS works, but
  65. __STDC__ is used in many Turbo C header files, and can confuse things.
  66. It would also mean that all flex-generated code must be compiled with
  67. that flag.
  68.  
  69. flexdef.h also had one small problem:
  70.  
  71.     44,46c44
  72.     < #ifndef MS_DOS
  73.     < char *memset();        /*  should be declared in string.h  */
  74.     < #endif
  75.     ---
  76.     > char *memset();
  77.  
  78. as the Turbo C definiton of memset() is:
  79.     void *memset(void *s, int c, size_t n);
  80.  
  81. The 128-byte command line limit of MS-DOS prevents us from using tcc to
  82. link the objects together, so I provide a tlink script, flex.lnk:
  83. -----
  84. \turboc\lib\c0l+
  85. ccl+
  86. dfa+
  87. ecs+
  88. gen+
  89. main+
  90. misc+
  91. nfa+
  92. parse+
  93. scan+
  94. sym+
  95. tblcmp+
  96. yylex
  97. flex.exe
  98.  
  99. \turboc\lib\cl
  100. -----
  101.  
  102. The blank line is required.
  103.  
  104. The makefile needed a lot of hacking, so here it is in its entirety.
  105. I don't think it is completely finished, but I'll be happy to work on
  106. it more if you'd like.  Some of the changes are specific to my environment
  107. (my yacc outputs ytab.c and ytab.h) and most MS-DOS people won't have
  108. cp, mv and rm.  Some people like separate makefiles for different
  109. systems, but we like one makefile with obscene parameterization.
  110.  
  111. I should note that all of my experiments with FLEX_FLAGS=-{c,f,F,e}
  112. have failed, mostly due to scan.c becoming too large to be a single
  113. module.  Damn toy operating system.
  114. -----
  115. # make file for "flex" tool
  116.  
  117. # @(#) $Header: Makefile,v 2.3 89/06/20 17:27:12 vern Exp $ (LBL)
  118.  
  119. # Porting considerations:
  120. #
  121. #    For BSD machines:
  122. #  CFLAGS =
  123. #  LDFLAGS = -s
  124. #  LINK = $(CC) $(CFLAGS) -o flex $(LDFLAGS) $(FLEXOBJS)
  125. #  SKELETON_DIR = .
  126. #  SKELETON_FILE = flex.skel
  127. #  SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\"
  128. #  O = o
  129. #  YTAB = y.tab
  130. #  FLEX = ./flex
  131. #
  132. #    For System V Unix or Vax/VMS machines, merely add:
  133. #  CFLAGS = -DSYS_V
  134. #
  135. #    For MS-DOS, Turbo C:
  136. CC = tcc
  137. CFLAGS = -DSYS_V -DMS_DOS -O -G -Z -ml -v
  138. LINK = tlink @flex.lnk/c/x/v
  139. SKELETON_DIR = .
  140. SKELETON_FILE = flex.skl
  141. SKELFLAGS = -DDEFAULT_SKELETON_FILE="$(SKELETON_DIR)/$(SKELETON_FILE)"
  142. O = obj
  143. EXE = .exe
  144. YTAB = ytab
  145. FLEX = flex
  146.  
  147. #
  148. # the first time around use "make first_flex"
  149. #
  150.  
  151. FLEX_FLAGS =
  152.  
  153. FLEXOBJS = \
  154.     ccl.$O \
  155.     dfa.$O \
  156.     ecs.$O \
  157.     gen.$O \
  158.     main.$O \
  159.     misc.$O \
  160.     nfa.$O \
  161.     parse.$O \
  162.     scan.$O \
  163.     sym.$O \
  164.     tblcmp.$O \
  165.     yylex.$O
  166.  
  167. FLEX_C_SOURCES = \
  168.     ccl.c \
  169.     dfa.c \
  170.     ecs.c \
  171.     gen.c \
  172.     main.c \
  173.     misc.c \
  174.     nfa.c \
  175.     parse.c \
  176.     scan.c \
  177.     sym.c \
  178.     tblcmp.c \
  179.     yylex.c
  180.  
  181. flex$(EXE): $(FLEXOBJS)
  182.     $(LINK)
  183.  
  184. first_flex:
  185.     cp initscan.c scan.c
  186.     $(MAKE) flex$(EXE)
  187.  
  188. parse.h parse.c: parse.y
  189.     $(YACC) -d parse.y
  190.     @mv $(YTAB).c parse.c
  191.     @mv $(YTAB).h parse.h
  192.  
  193. scan.c: scan.l
  194.     $(FLEX) -ist $(FLEX_FLAGS) scan.l >scan.c
  195.  
  196. scan.$O: scan.c parse.h
  197.  
  198. main.$O: main.c
  199.     $(CC) $(CFLAGS) -c $(SKELFLAGS) main.c
  200.  
  201. flex.man: flex.1
  202.     nroff -man flex.1 >flex.man
  203.  
  204. lint: $(FLEX_C_SOURCES)
  205.     lint $(FLEX_C_SOURCES) > flex.lint
  206.  
  207. distrib:
  208.     mv scan.c initscan.c
  209.     chmod 444 initscan.c
  210.     $(MAKE) clean
  211.  
  212. clean:
  213.     rm -f core errs flex *.$O parse.c *.lint parse.h flex.man tags
  214.  
  215. tags:
  216.     ctags $(FLEX_C_SOURCES)
  217.  
  218. vms:    flex.man
  219.     $(MAKE) distrib
  220.  
  221. test:
  222.     $(FLEX) -ist $(FLEX_FLAGS) scan.l | diff scan.c -
  223. -----
  224.  
  225. BTW, thanks for a great tool.
  226.  
  227. Frank Whaley
  228. Senior Development Engineer
  229. Quadratron Systems Incorporated
  230. few@quad1.quad.com
  231. uunet!ccicpg!quad1!few
  232. (Message inbox:8)
  233. Date:  Thu, 31 Aug 89 14:57:36 pst
  234. From:  few@quad1.quad.com (Frank Whaley)
  235. Subject:  Re: flex 2.1 for Turbo C
  236. To:  vern@cs.cornell.edu
  237.  
  238. > Thanks for the diffs and Makefile.  I'll endeavor to integrate them
  239. > into the next release.
  240.  
  241. One terribly important thing I forgot -- Turbo C (and most MS-DOS C
  242. compilers) provide only a 4K default stack.  Not having thoroughly
  243. tested flex, I can't say that this is enough.  The makefile I provided
  244. to you builds a version without stack checking code.  I would suggest
  245. adding "-N" to CFLAGS, which will include some simple stack overflow
  246. checking code.  You may wish to include the following lines to main.c:
  247.  
  248.     #ifdef __TURBOC__
  249.     unsigned _stklen = 16384;    /*  some reasonably large number  */
  250.     #endif
  251.  
  252. In addition, the flags in the makefile build a version with symbols
  253. for Turbo Debugger (like -g).  You may wan't to leave these flags off
  254. (remove "-v" from CFLAGS and "/v" from LINK) or you may wish to provide
  255. an "install" target like so:
  256.  
  257.     BINDIR = {/usr/local/bin | c:\bin}
  258.     STRIP = {strip | tdstrip}
  259.  
  260.     install: flex$(EXE)
  261.         $(CP) flex$(EXE) $(BINDIR)
  262.         $(STRIP) $(BINDIR)/flex$(EXE)
  263.  
  264. Regards,
  265.     few
  266.  
  267. few@quad1.quad.com
  268. uunet!ccicpg!quad1!few
  269.  
  270.